﻿// The base class for all the validators
define([
    'Wjs/ui/widgets/validation/Validator'
],
function () {
    'use strict';

    return Wjs.defineOnce({

        type: 'UrlValidator',

        internal: {
            base: Wjs.getType('Validator'),

            onTypeDefined: function (Validator) { // Register a default instance of the validator by alias
                var validator = new Validator(); // The default validator

                Wjs.getType('validatorManager').register(validator);
            }
        },

        alias: 'url',

        // The error message to display on error
        message: 'The url in field [${fieldName}] is invalid',

        regex: /^((http|https):\/\/(\w+:{0,1}\w*@)?(\S+)|)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/
    });

});